#!/usr/bin/python

import sys 

wc = {} 

for eachLine in sys.stdin:
    eachLine = eachLine.strip()
    if(eachLine.find("\t") != -1 and len(eachLine.split("\t")) >= 2):
        word = eachLine.split("\t")[0]
        art_name = eachLine.split("\t")[1]
        
        if(wc.has_key(word) == False):
            wc[word] = ""
        
        wc[word] += art_name + "\t" 


for eachWord in wc.keys():
    result = eachWord + "\t" + wc[eachWord]
    try:
        print result
    except:
        continue

